<div id="maincontent">
	<div id="content">
    <div class="box1">
      <h3><?php echo str_replace("#num#", intval($_GET['a']), lico_lang('general', 'machine.page.title1')); ?></h3>
      <div class="description"><?php echo lico_lang('general', 'machine.page.description1'); ?></div>
      
      <?php
      if (isset($_GET['a']) && intval($_GET['a']) >= 1) {
        $machineid = intval($_GET['a']);
      }
      $desc = lico_lang('machine', 'certificate.description');
      ?>
      <div id="personal-certificate">
        
        <div id="certificate">
          <label class="certificate-label"><?php echo $desc; ?></label>
          <span class="certificate-value"><a href="<?php echo $lico['baseurl.ssl']; ?>/machine/<?php echo $machineid; ?>.html"><img src="/mcert/<?php echo $machineid; ?>.png" alt="Certificate for machine #<?php echo $machineid; ?>" title="Certificate for machine #<?php echo $machineid; ?>"/></a></span>
        </div>
        
        
      </div>
    </div>
		


    <div class="box2">
      <h3><?php echo str_replace("#num#", intval($_GET['a']), lico_lang('general', 'machine.page.title2')); ?></h3>
        <div class="description"><?php echo lico_lang('general', 'machine.page.description2'); ?></div>
      
<?php

if (isset($_GET['a']) && intval($_GET['a']) >= 1) {
  $machineid = intval($_GET['a']);
  $select = "SELECT *, UNIX_TIMESTAMP(f_ctime) AS ctime, UNIX_TIMESTAMP(f_mtime) AS mtime FROM `machines` WHERE `f_key`='".lico_ESC($machineid)."'";
	$ret = $db->getAll_assoc($select);
	if (count($ret) <= 0) {
  } else {
		$id = intval($ret[0]['f_key']);
    $ctime = lico_getdatetime(intval($ret[0]['ctime']));
    $mtime = lico_getdatetime(intval($ret[0]['mtime']));
    $name = trim($ret[0]['name']);
    $owner = trim($ret[0]['owner']);
    $select = "SELECT * FROM `processors` WHERE `f_key`='".lico_ESC($ret[0]['cpu'])."'";
    $selcpu = $db->unbuffered_query_first($select);
    $cpu = trim($selcpu[1]);
    if (trim($selcpu[2]) != "")
      $cpu .= " @ ".trim($selcpu[2]);
    $cpunum = intval($ret[0]['cpunum']);
    $accounts = intval($ret[0]['accounts']);
    $country = trim($ret[0]['country']);
    $disk = intval($ret[0]['disk']);
    $distribution = trim($ret[0]['distribution']);
    $distversion = trim($ret[0]['distversion']);
    $mailer = trim($ret[0]['mailer']);
    $memory = intval($ret[0]['memory']);
    $network = trim($ret[0]['network']);
    $purpose = trim($ret[0]['purpose']);
    $source = trim($ret[0]['source']);
    $users = intval($ret[0]['users']);
    $sysclass = trim($ret[0]['sysclass']);
    
    $diskfree = intval($ret[0]['diskfree']);
    $memfree = intval($ret[0]['memfree']);
    $swap = intval($ret[0]['swap']);
    $swapfree = intval($ret[0]['swapfree']);
    $cpuflags = trim($ret[0]['cpuflags']);
    $arch = trim($ret[0]['arch']);
    $kernel = trim($ret[0]['kernel']);
    $online = trim($ret[0]['online']);
    $uptime = trim($ret[0]['uptime']);
    
    $uptime = lico_getUptimeFormatted($uptime);
    $disk = lico_GetFormattedBytes($disk);
    $diskfree = lico_GetFormattedBytes($diskfree);
    $memory = lico_GetFormattedBytes($memory);
    $memfree = lico_GetFormattedBytes($memfree);
    $swap = lico_GetFormattedBytes($swap);
    $swapfree = lico_GetFormattedBytes($swapfree);
    
    $publish_hostname = trim($ret[0]['publish_hostname']);
    $publish_versions = trim($ret[0]['publish_versions']);
    $publish_cpuinfo = trim($ret[0]['publish_cpuinfo']);
    $publish_sizeinfo = trim($ret[0]['publish_sizeinfo']);
    $isactive = trim($ret[0]['isactive']);
    
    $purpose = str_replace(",", ", ", $purpose);
    /*
    if (preg_match("`,`", $purpose)) {
      $purpose = explode(",", $purpose);
    } else {
      $purpose = array($purpose);
    }
    $porposealternative = "";
    if (!in_array($purpose[count($purpose)-1], $lico['purposes']))
      $porposealternative = $purpose[count($purpose)-1];
    */
    $out .= "     <div id=\"machine-information\">\n";
    $out .= "       <div class=\"infoitem even\">\n";
    $out .= "         <label class=\"infolabel\">".lico_lang('machine', 'user.number').":</label>\n";
    $out .= "         <span class=\"infovalue\"><a href=\"/user/".$owner.".html\"><strong>#".$owner."</strong></a></span>\n";
    $out .= "       </div>\n";
    $out .= "       <div class=\"infoitem odd\">\n";
    $out .= "         <label class=\"infolabel\">".lico_lang('profile', 'name').":</label>\n";
    $out .= "         <span class=\"infovalue\">".($publish_hostname=="YES"?$name:"SECRET")."</span>\n";
    $out .= "       </div>\n";
    $out .= "       <div class=\"infoitem even\">\n";
    $out .= "         <label class=\"infolabel\">".lico_lang('profile', 'uptime').":</label>\n";
    $out .= "         <span class=\"infovalue\">".$uptime."</span>\n";
    $out .= "       </div>\n";
    $out .= "       <div class=\"infoitem odd\">\n";
    $out .= "         <label class=\"infolabel\">".lico_lang('profile', 'country').":</label>\n";
    $out .= "         <span class=\"infovalue\">".$country."</span>\n";
    $out .= "       </div>\n";
    $out .= "       <div class=\"infoitem even\">\n";
    $out .= "         <label class=\"infolabel\">".lico_lang('profile', 'purpose').":</label>\n";
    $out .= "         <span class=\"infovalue\">".$purpose."</span>\n";
    $out .= "       </div>\n";
    $out .= "       <div class=\"infoitem odd\">\n";
    $out .= "         <label class=\"infolabel\">".lico_lang('profile', 'sysclass').":</label>\n";
    $out .= "         <span class=\"infovalue\">".($sysclass!=""?lico_lang('profile', $sysclass):"")."</span>\n";
    $out .= "       </div>\n";
    $out .= "       <div class=\"infoitem even\">\n";
    $out .= "         <label class=\"infolabel\">".lico_lang('profile', 'cpu').":</label>\n";
    $out .= "         <span class=\"infovalue\">".($publish_cpuinfo=="YES"?$cpu:"SECRET")."</span>\n";
    $out .= "       </div>\n";
    $out .= "       <div class=\"infoitem odd\">\n";
    $out .= "         <label class=\"infolabel\">".lico_lang('profile', 'cpunum').":</label>\n";
    $out .= "         <span class=\"infovalue\">".$cpunum."</span>\n";
    $out .= "       </div>\n";

    $out .= "       <div class=\"infoitem even\">\n";
    $out .= "         <label class=\"infolabel\">".lico_lang('profile', 'cpuflags').":</label>\n";
    $out .= "         <span class=\"infovalue\">".($publish_cpuinfo=="YES"?$cpuflags:"SECRET")."</span>\n";
    $out .= "       </div>\n";

    $out .= "       <div class=\"infoitem odd\">\n";
    $out .= "         <label class=\"infolabel\">".lico_lang('profile', 'arch').":</label>\n";
    $out .= "         <span class=\"infovalue\">".($publish_versions=="YES"?$arch:"SECRET")."</span>\n";
    $out .= "       </div>\n";

    $out .= "       <div class=\"infoitem even\">\n";
    $out .= "         <label class=\"infolabel\">".lico_lang('profile', 'kernel').":</label>\n";
    $out .= "         <span class=\"infovalue\">".($publish_versions=="YES"?$kernel:"SECRET")."</span>\n";
    $out .= "       </div>\n";

    $out .= "       <div class=\"infoitem even\">\n";
    $out .= "         <label class=\"infolabel\">".lico_lang('profile', 'memory').":</label>\n";
    $out .= "         <span class=\"infovalue\">".($publish_sizeinfo=="YES"?$memory:"SECRET")."</span>\n";
    $out .= "       </div>\n";

    $out .= "       <div class=\"infoitem odd\">\n";
    $out .= "         <label class=\"infolabel\">".lico_lang('profile', 'memory.free').":</label>\n";
    $out .= "         <span class=\"infovalue\">".($publish_sizeinfo=="YES"?$memfree:"SECRET")."</span>\n";
    $out .= "       </div>\n";

    $out .= "       <div class=\"infoitem even\">\n";
    $out .= "         <label class=\"infolabel\">".lico_lang('profile', 'swap').":</label>\n";
    $out .= "         <span class=\"infovalue\">".($publish_sizeinfo=="YES"?$swap:"SECRET")."</span>\n";
    $out .= "       </div>\n";

    $out .= "       <div class=\"infoitem odd\">\n";
    $out .= "         <label class=\"infolabel\">".lico_lang('profile', 'swap.free').":</label>\n";
    $out .= "         <span class=\"infovalue\">".($publish_sizeinfo=="YES"?$swapfree:"SECRET")."</span>\n";
    $out .= "       </div>\n";

    $out .= "       <div class=\"infoitem even\">\n";
    $out .= "         <label class=\"infolabel\">".lico_lang('profile', 'disk').":</label>\n";
    $out .= "         <span class=\"infovalue\">".($publish_sizeinfo=="YES"?$disk:"SECRET")."</span>\n";
    $out .= "       </div>\n";

    $out .= "       <div class=\"infoitem odd\">\n";
    $out .= "         <label class=\"infolabel\">".lico_lang('profile', 'disk.free').":</label>\n";
    $out .= "         <span class=\"infovalue\">".($publish_sizeinfo=="YES"?$diskfree:"SECRET")."</span>\n";
    $out .= "       </div>\n";

    $out .= "       <div class=\"infoitem even\">\n";
    $out .= "         <label class=\"infolabel\">".lico_lang('profile', 'network').":</label>\n";
    $out .= "         <span class=\"infovalue\">".$network."</span>\n";
    $out .= "       </div>\n";
    $out .= "       <div class=\"infoitem odd\">\n";
    $out .= "         <label class=\"infolabel\">".lico_lang('profile', 'distribution').":</label>\n";
    $out .= "         <span class=\"infovalue\">".$distribution."</span>\n";
    $out .= "       </div>\n";
    $out .= "       <div class=\"infoitem even\">\n";
    $out .= "         <label class=\"infolabel\">".lico_lang('profile', 'distribution.version').":</label>\n";
    $out .= "         <span class=\"infovalue\">".($publish_versions=="YES"?$distversion:"SECRET")."</span>\n";
    $out .= "       </div>\n";
    $out .= "       <div class=\"infoitem odd\">\n";
    $out .= "         <label class=\"infolabel\">".lico_lang('profile', 'mailer').":</label>\n";
    $out .= "         <span class=\"infovalue\">".$mailer."</span>\n";
    $out .= "       </div>\n";
    $out .= "       <div class=\"infoitem even\">\n";
    $out .= "         <label class=\"infolabel\">".lico_lang('profile', 'users').":</label>\n";
    $out .= "         <span class=\"infovalue\">".$users."</span>\n";
    $out .= "       </div>\n";
    $out .= "       <div class=\"infoitem odd\">\n";
    $out .= "         <label class=\"infolabel\">".lico_lang('profile', 'accounts').":</label>\n";
    $out .= "         <span class=\"infovalue\">".$accounts."</span>\n";
    $out .= "       </div>\n";
    $out .= "     </div>\n";
    echo $out;
  }
}

?>      
      
      
      
    </div>
  </div>
</div>
